package gui.abstracts;

import gui.tables.models.MyTableModel;

import javax.swing.DefaultListSelectionModel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

public abstract class AbstractTable extends JTable {
	protected DefaultTableModel tableMOdel;
	protected boolean isSelectedOne = false;
	protected int selectedRow;

	public void setEdit(boolean editRow) {

		isSelectedOne = editRow;
		((MyTableModel)tableMOdel).setEdit(editRow);

	}

	public DefaultTableModel getDefaultTableMOdel() {
		return this.tableMOdel;
	}

	public void setLastRow(int lastRow) {
		((MyTableModel) tableMOdel).setLastRow(lastRow);
		selectedRow = lastRow;

	}

	public int getLastRow() {

		return ((MyTableModel) tableMOdel).getLastRow();
	}

	public void setIdAfterInsert(int iD) {

		this.setValueAt(iD, this.getRowCount() - 1, 0);
	}

	public void cancelInsertRow() {
		tableMOdel.removeRow(this.getRowCount() - 1);
	}

	abstract public void insertRowInTable();

	public int getSelectedRow() {
		return super.getSelectedRow();
	}

}
